'use strict';
define(['../main'],function(module){
    module.controller("depositRechargeCtrl",function($scope,$http,$rootScope){
        $rootScope.navActive='/web/deposit';
        $scope.depositType=[];
        $scope.currentDepositType;                              //当前备用金类型
        $scope.startTime=$rootScope.commonUtil.addDate(-1);     //开始时间
        $scope.endTime=$rootScope.commonUtil.addDate(-1);       //结束时间
        $scope.searchKey='';            //关键字
        $scope.rechargeData={            //备用金余额数据
            pageNum:1,
            pageSize:20,
            list:[]
        };
        /**
         * 初始化下拉框
         */
        var initSelector=function(){
            $http.get("api/deposit/depositList").success(function(data){
                $scope.depositType=data.optType;
                $scope.currentDepositType=$scope.depositType[0];
            });
        };
        $scope.searchRecharge=function(page){
            var param={
                startTime:$scope.startTime,
                endTime:$scope.endTime,
                optType:$scope.currentDepositType.key,
                searchKey:$scope.searchKey,
                pageNum:page,
                pageSize:$scope.rechargeData.pageSize
            };
            $http.get("api/deposit/rechargeRecord",{params:param}).success(function(data){
                $scope.rechargeData=data;
                console.log(data);
            });
        };
        $scope.exportRecharge=function(){
            $("#exportForm").submit();
        };
        initSelector();
    });
});
